<template>
  <div>
    <OneTry
    v-for="item in list"
    :key="item.id"
    :title="item.proname"
    :price="item.proprice"
    :info="msg"
    :num="item.id"
    @sayPrice="sayPrice"
     />
  </div>
</template>

<script>
// 引入
import OneTry from './components/OneTry.vue'
// 注册
// 使用

// 父向子传值
export default {
  components: {
    OneTry
  },
  data() {
    return {
      list: [
        { id: 1, proname: '超级无敌椰子鸡儿', proprice: 69 },
        { id: 2, proname: '超级无敌棒棒鸡儿', proprice: 59 },
        { id: 3, proname: '超级无敌钵钵鸡儿', proprice: 49 }
      ],
      msg: '美味!'
    };
  },
  methods: {
   sayPrice(num) {
    const i = this.list.find(item => item.id == num)
    // console.log(i)
    i.proprice <=2 ? i.proprice = i.proprice : i.proprice -= 2
   }
  }
};
</script>

<style scoped>

</style>